From 40d4df2ba03a9fea139fe1b1d1edc0cc99eb99b5 Mon Sep 17 00:00:00 2001 From: Robert Lipe Date: Fri, 13 Mar 2020 00:35:53 -0500 Subject: [PATCH] Dont count ending fencepost when interpolating TimeSpan in KML reader. --- kml.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kml.cc b/kml.cc index 1302fb3cf..7312df325 100644 --- a/kml.cc +++ b/kml.cc @@ -449,7 +449,10 @@ void trk_coord(xg_string args, const QXmlStreamAttributes*) // If there are some Waypoints, then distribute the TimeSpan to all Waypoints if (trk_head->rte_waypt_ct > 0) { qint64 timespan_ms = wpt_timespan_begin.msecsTo(wpt_timespan_end); - qint64 ms_per_waypoint = timespan_ms / trk_head->rte_waypt_ct; + if (trk_head->rte_waypt_ct < 2) { + fatal(MYNAME ": attempt to interpolate TimeSpan with too few points."); + } + qint64 ms_per_waypoint = timespan_ms / (trk_head->rte_waypt_ct - 1); foreach (Waypoint* trackpoint, trk_head->waypoint_list) { trackpoint->SetCreationTime(wpt_timespan_begin); wpt_timespan_begin = wpt_timespan_begin.addMSecs(ms_per_waypoint); -- 2.30.2